<template>
  <a-card title="所有业务">
<!--    <template slot="extra">-->
<!--      <a-button type="danger">批量保存</a-button>-->
<!--    </template>-->
    <div class="table-page-search-wrapper">
      <a-form-model
        layout="inline"
        :model="queryParam"
      >
        <a-row :gutter="15">
          <a-col :md="6" :sm="24">
            <a-form-model-item label="业务标识">
              <a-input v-model="queryParam['filter[mark]']" placeholder="请输入业务标识"/>
            </a-form-model-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-model-item label="业务名称">
              <a-input v-model="queryParam['filter[name]']" placeholder="请输入业务名称"/>
            </a-form-model-item>
          </a-col>
          <template v-if="advanced">
            <a-col :md="6" :sm="24">
              <a-form-model-item label="是否显示">
                <a-select v-model="queryParam['filter[hide]']" placeholder="请选择是否显示">
                  <a-select-option :value="1">是</a-select-option>
                  <a-select-option :value="0">否</a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="所在组别">
                <a-select v-model="queryParam['filter[cat_group]']" placeholder="请选择组别">
                  <a-select-option v-for="(item,index) in groupOpts" :key="index" :value="index">
                    {{ item }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
          </template>
          <a-col :md="!advanced && 8 || 24" :sm="24">
                <span class='table-page-search-submitButtons' :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
                  <a-button type="primary" @click="$refs.table.refresh(true)">搜索</a-button>
                  <a-button style="margin-left: 8px" @click="resetForm">重置</a-button>
                </span>
          </a-col>
        </a-row>
      </a-form-model>
    </div>
    <div class="table-operator">
      <s-table
        bordered
        ref="table"
        :row-key="(record) => record.business_id"
        :columns="priceColumns"
        :data="priceData"
      >
        <template slot="mark" slot-scope="text">
          {{text}}
        </template>
        <template slot="name" slot-scope="text">
          {{text}}
        </template>
        <template slot="cat_group" slot-scope="text">
          <div v-for="(item,index) in groupOpts" :key="index" :value="index">
            <div v-if="index == text">{{item}}</div>
          </div>
        </template>
        <template slot="official_fee" slot-scope="text">
          {{text}}
        </template>
        <template slot="vip_offer_section_lft" slot-scope="text">
          {{text}}
        </template>
        <template slot="offer_section_lft" slot-scope="text">
          {{text}}
        </template>
        <template slot="offer_section_rgt" slot-scope="text">
          {{text}}
        </template>
        <template slot="hide" slot-scope="text">
          <a-tag color="red" v-if="text == 1">显示</a-tag>
          <a-tag v-else>隐藏</a-tag>
        </template>
        <template slot="action">
          <a-button type="primary" size="small">编辑</a-button>
        </template>
      </s-table>
    </div>
  </a-card>
</template>

<script>
import { STable } from '@/components'
import priceColumns from '@/columns/business'
import { getPatentBusiness } from '@/api/patent.process'

export default {
  props: {
    isType: {
      type: Number,
      default: 1
    }
  },
  components: {
    STable
  },
  name: 'BusinessPrice',
  data () {
    return {
      priceColumns: priceColumns.price,
      priceData: parameters => {
        return getPatentBusiness(Object.assign(parameters, this.queryParam)).then(res => {
          this.groupOpts = res.result.category20Opts
          return res.result
        })
      },
      queryParam: {},
      advanced: true,
      groupOpts: {}
    }
  },
  methods: {
    resetForm () {
      this.queryParam = {}
      this.$refs.table.refresh(true)
    }
  }
}
</script>

<style scoped>

</style>
